library(sp)
library(sf)
## Linking to GEOS 3.9.1, GDAL 3.2.1, PROJ 7.2.1
library(rgdal)
## Please note that rgdal will be retired by the end of 2023,
## plan transition to sf/stars/terra functions using GDAL and PROJ
## at your earliest convenience.
##
## rgdal: version: 1.5-27, (SVN revision 1148)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 3.2.1, released 2020/12/29
## Path to GDAL shared files: C:/Users/prabhdeep/Documents/R/win-library/4.1/rgdal/gdal
## GDAL binary built with GEOS: TRUE
## Loaded PROJ runtime: Rel. 7.2.1, January 1st, 2021, [PJ_VERSION: 721]
## Path to PROJ shared files: C:/Users/prabhdeep/Documents/R/win-library/4.1/rgdal/proj
## PROJ CDN enabled: FALSE
## Linking to sp version:1.4-5
## To mute warnings of possible GDAL/OSR exportToProj4() degradation,
## use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
## Overwritten PROJ_LIB was C:/Users/prabhdeep/Documents/R/win-library/4.1/rgdal/proj
library(classInt)
library(RColorBrewer) # not a strictly a spatial ligrary
library(viridis) #my current "go to" color scales
## Loading required package: viridisLite
library(ggmap)
## Loading required package: ggplot2
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
library(leaflet)
library(tmap)
## Registered S3 methods overwritten by 'stars':
## method from
## st_bbox.SpatRaster sf
## st_crs.SpatRaster sf
library(GISTools)
## Loading required package: maptools
## Checking rgeos availability: TRUE
## Please note that 'maptools' will be retired by the end of 2023,
## plan transition at your earliest convenience;
## some functionality will be moved to 'sp'.
## Loading required package: MASS
## Loading required package: rgeos
## rgeos version: 0.5-8, (SVN revision 679)
## GEOS runtime version: 3.9.1-CAPI-1.14.2
## Please note that rgeos will be retired by the end of 2023,
## plan transition to sf functions using GEOS at your earliest convenience.
## GEOS using OverlayNG
## Linking to sp version: 1.4-5
## Polygon checking: TRUE
library(knitr) # to create nice documents in R
library(tidyverse) # loads ggplot2, dplyr,tidyr,readr,purr,tibble
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v tibble 3.1.5 v dplyr 1.0.7
## v tidyr 1.1.4 v stringr 1.4.0
## v readr 2.0.2 v forcats 0.5.1
## v purrr 0.3.4
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## x dplyr::select() masks MASS::select()
library(broom) # because I find it useful
library(forcats) # working with categorical variables
whiskey <- read_csv("Real whiskey dataset.csv")
## Rows: 86 Columns: 17
## -- Column specification --------------------------------------------------------
## Delimiter: ","
## chr (2): Distillery, Postcode
## dbl (15): RowID, Body, Sweetness, Smoky, Medicinal, Tobacco, Honey, Spicy, W...
##
## i Use `spec()` to retrieve the full column specification for this data.
## i Specify the column types or set `show_col_types = FALSE` to quiet this message.
whiskey$Longitude <- as.numeric(whiskey$Longitude)
whiskey$Latitude <- as.numeric(whiskey$Latitude)
str(whiskey)
## spec_tbl_df [86 x 17] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
## $ RowID : num [1:86] 1 2 3 4 5 6 7 8 9 10 ...
## $ Distillery: chr [1:86] "Aberfeldy" "Aberlour" "AnCnoc" "Ardbeg" ...
## $ Body : num [1:86] 2 3 1 4 2 2 0 2 2 2 ...
## $ Sweetness : num [1:86] 2 3 3 1 2 3 2 3 2 3 ...
## $ Smoky : num [1:86] 2 1 2 4 2 1 0 1 1 2 ...
## $ Medicinal : num [1:86] 0 0 0 4 0 1 0 0 0 1 ...
## $ Tobacco : num [1:86] 0 0 0 0 0 0 0 0 0 0 ...
## $ Honey : num [1:86] 2 4 2 0 1 1 1 2 1 0 ...
## $ Spicy : num [1:86] 1 3 0 2 1 1 1 1 0 2 ...
## $ Winey : num [1:86] 2 2 0 0 1 1 0 2 0 0 ...
## $ Nutty : num [1:86] 2 2 2 1 2 0 2 2 2 2 ...
## $ Malty : num [1:86] 2 3 2 2 3 1 2 2 2 1 ...
## $ Fruity : num [1:86] 2 3 3 1 1 1 3 2 2 2 ...
## $ Floral : num [1:86] 2 2 2 0 1 2 3 1 2 1 ...
## $ Postcode : chr [1:86] "PH15 2EB" "AB38 9PJ" "AB5 5LI" "PA42 7EB" ...
## $ Latitude : num [1:86] 286580 326340 352960 141560 355350 ...
## $ Longitude : num [1:86] 749680 842570 839320 646220 829140 ...
## - attr(*, "spec")=
## .. cols(
## .. RowID = col_double(),
## .. Distillery = col_character(),
## .. Body = col_double(),
## .. Sweetness = col_double(),
## .. Smoky = col_double(),
## .. Medicinal = col_double(),
## .. Tobacco = col_double(),
## .. Honey = col_double(),
## .. Spicy = col_double(),
## .. Winey = col_double(),
## .. Nutty = col_double(),
## .. Malty = col_double(),
## .. Fruity = col_double(),
## .. Floral = col_double(),
## .. Postcode = col_character(),
## .. Latitude = col_double(),
## .. Longitude = col_double()
## .. )
## - attr(*, "problems")=<externalptr>
library(maps)
##
## Attaching package: 'maps'
## The following object is masked from 'package:purrr':
##
## map
## The following object is masked from 'package:GISTools':
##
## map.scale
## The following object is masked from 'package:viridis':
##
## unemp
world.map <- map_data ("world")
glimpse(world.map)
## Rows: 99,338
## Columns: 6
## $ long <dbl> -69.89912, -69.89571, -69.94219, -70.00415, -70.06612, -70.0~
## $ lat <dbl> 12.45200, 12.42300, 12.43853, 12.50049, 12.54697, 12.59707, ~
## $ group <dbl> 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, ~
## $ order <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 1~
## $ region <chr> "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba", "Aruba~
## $ subregion <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, ~
UK.map <- world.map %>% filter(region == "UK")
whiskies.coord <- data.frame(whiskey$Latitude, whiskey$Longitude)
coordinates(whiskies.coord) <- ~whiskey.Latitude + whiskey.Longitude
proj4string(whiskies.coord) <- CRS("+init=epsg:27700")
## Warning in showSRID(uprojargs, format = "PROJ", multiline = "NO", prefer_proj =
## prefer_proj): Discarded datum OSGB_1936 in Proj4 definition
whiskies.coord <- spTransform(whiskies.coord, CRS("+init=epsg:4326"))
whisky.map <- data.frame(Distillery = whiskey$Distillery,
lat = whiskies.coord$whiskey.Latitude,
long = whiskies.coord$whiskey.Longitude)
UK.map %>%
filter(subregion == "Scotland") %>% ggplot() +
geom_map(map = UK.map,aes(x = long, y = lat, map_id = region),fill="White", colour = "Black")+ coord_map() + geom_point(data = whisky.map,aes(x=lat, y = long, colour = "red", alpha = 0.9))
## Warning: Ignoring unknown aesthetics: x, y
whiskey_db<-cbind(whisky.map,whiskey$Body,whiskey$Sweetness,whiskey$Smoky,whiskey$Medicinal,whiskey$Tobacco,whiskey$Honey,whiskey$Spicy,whiskey$Winey,whiskey$Nutty,whiskey$Malty,whiskey$Fruity,whiskey$Floral,whiskey$Postcode)
library(leaflet)
library(dplyr)
map<-leaflet()%>%
addTiles()%>%
addProviderTiles(providers$OpenStreetMap)%>%
addMarkers(lng=UK.map$long,lat=UK.map$lat)
map
library(leaflet)
library(dplyr)
map<-leaflet()%>%
addTiles()%>%
addProviderTiles(providers$OpenStreetMap)%>%
addMarkers(lng=UK.map$long,lat=UK.map$lat,popup=paste("Distillery name:",whiskey_db$Distiller,"<br>","Body:",whiskey$Body,"<br>","Sweetness:",whiskey$Sweetness,"<br>","Smoky:",whiskey$Smoky,"<br>","Medicinal:",whiskey$Medicinal,"<br>","Tobacco:",whiskey$Tobacco,"<br>","Honey:",whiskey$Honey,"<br>","Spicy:",whiskey$Spicy,"<br>","Winey:",whiskey$Winey,"<br>","Nutty:",whiskey$Nutty,"<br>","Malty:",whiskey$Malty,"<br>","Fruity:",whiskey$Fruity,"<br>","Floral:",whiskey$Floral,"<br>","Postcode:",whiskey$Postcode,"<br>","Lattitude:",whiskey$Latitude,"<br>","Longitude:",whiskey$Longitude))
map
#
library(leaflet)
library(dplyr)
newicon<-makeIcon(iconUrl="https://th.bing.com/th/id/R.ea3d8777c865475529457f6bdae5cdad?rik=Gdii5m0%2b54%2fUpw&riu=http%3a%2f%2fpngimg.com%2fuploads%2fwhisky%2fwhisky_PNG62.png&ehk=fO165RiE%2f61zY9bzAjVu1nQ1t%2b18iLob4YToocqd2LQ%3d&risl=&pid=ImgRaw&r=0",iconWidth=35,iconHeight=75)
map<-leaflet()%>%
addTiles()%>%
addProviderTiles(providers$OpenStreetMap)%>%
addMarkers(lng=UK.map$long,lat=UK.map$lat,icon=newicon,popup=paste("Distillery name:",whiskey_db$Distiller,"<br>","Body:",whiskey$Body,"<br>","Sweetness:",whiskey$Sweetness,"<br>","Smoky:",whiskey$Smoky,"<br>","Medicinal:",whiskey$Medicinal,"<br>","Tobacco:",whiskey$Tobacco,"<br>","Honey:",whiskey$Honey,"<br>","Spicy:",whiskey$Spicy,"<br>","Winey:",whiskey$Winey,"<br>","Nutty:",whiskey$Nutty,"<br>","Malty:",whiskey$Malty,"<br>","Fruity:",whiskey$Fruity,"<br>","Floral:",whiskey$Floral,"<br>","Postcode:",whiskey$Postcode,"<br>","Lattitude:",whiskey$Latitude,"<br>","Longitude:",whiskey$Longitude))
map
#
library(leaflet)
library(dplyr)
newicon<-makeIcon(iconUrl="https://cdn0.iconfinder.com/data/icons/alcoholic/120/bourbon1-512.png",iconWidth=50,iconHeight=65)
map<-leaflet()%>%
addTiles()%>%
addProviderTiles(providers$OpenStreetMap)%>%
addMarkers(lng=UK.map$long,lat=UK.map$lat,icon=newicon,popup=paste("Distillery name:",whiskey_db$Distiller,"<br>","Body:",whiskey$Body,"<br>","Sweetness:",whiskey$Sweetness,"<br>","Smoky:",whiskey$Smoky,"<br>","Medicinal:",whiskey$Medicinal,"<br>","Tobacco:",whiskey$Tobacco,"<br>","Honey:",whiskey$Honey,"<br>","Spicy:",whiskey$Spicy,"<br>","Winey:",whiskey$Winey,"<br>","Nutty:",whiskey$Nutty,"<br>","Malty:",whiskey$Malty,"<br>","Fruity:",whiskey$Fruity,"<br>","Floral:",whiskey$Floral,"<br>","Postcode:",whiskey$Postcode,"<br>","Lattitude:",whiskey$Latitude,"<br>","Longitude:",whiskey$Longitude))
setView(map,lng=-2.4333,lat=53.5500,zoom=9)
#
library(leaflet)
library(dplyr)
newicon<-makeIcon(iconUrl="https://cdn0.iconfinder.com/data/icons/alcoholic/120/bourbon1-512.png",iconWidth=50,iconHeight=65)
map<-leaflet()%>%
addTiles()%>%
addProviderTiles(providers$OpenStreetMap)%>%
addMarkers(lng=UK.map$long,lat=UK.map$lat,icon=newicon,popup=paste("Distillery name:",whiskey_db$Distiller,"<br>","Body:",whiskey$Body,"<br>","Sweetness:",whiskey$Sweetness,"<br>","Smoky:",whiskey$Smoky,"<br>","Medicinal:",whiskey$Medicinal,"<br>","Tobacco:",whiskey$Tobacco,"<br>","Honey:",whiskey$Honey,"<br>","Spicy:",whiskey$Spicy,"<br>","Winey:",whiskey$Winey,"<br>","Nutty:",whiskey$Nutty,"<br>","Malty:",whiskey$Malty,"<br>","Fruity:",whiskey$Fruity,"<br>","Floral:",whiskey$Floral,"<br>","Postcode:",whiskey$Postcode,"<br>","Lattitude:",whiskey$Latitude,"<br>","Longitude:",whiskey$Longitude))%>%addMiniMap()
setView(map,lng=-2.4333,lat=53.5500,zoom=9)
library(leaflet)
library(dplyr)
newicon<-makeIcon(iconUrl="https://cdn0.iconfinder.com/data/icons/alcoholic/120/bourbon1-512.png",iconWidth=50,iconHeight=65)
map<-leaflet()%>%
addTiles()%>%
addProviderTiles(providers$OpenStreetMap)%>%
addMarkers(lng=UK.map$long,lat=UK.map$lat,icon=newicon,clusterOptions = markerClusterOptions(),popup=paste("Distillery name:",whiskey_db$Distiller,"<br>","Body:",whiskey$Body,"<br>","Sweetness:",whiskey$Sweetness,"<br>","Smoky:",whiskey$Smoky,"<br>","Medicinal:",whiskey$Medicinal,"<br>","Tobacco:",whiskey$Tobacco,"<br>","Honey:",whiskey$Honey,"<br>","Spicy:",whiskey$Spicy,"<br>","Winey:",whiskey$Winey,"<br>","Nutty:",whiskey$Nutty,"<br>","Malty:",whiskey$Malty,"<br>","Fruity:",whiskey$Fruity,"<br>","Floral:",whiskey$Floral,"<br>","Postcode:",whiskey$Postcode,"<br>","Lattitude:",whiskey$Latitude,"<br>","Longitude:",whiskey$Longitude))%>%addMiniMap()
setView(map,lng=-2.4333,lat=53.5500,zoom=9)
library(leaflet)
library(dplyr)
newicon<-makeIcon(iconUrl="https://cdn0.iconfinder.com/data/icons/alcoholic/120/bourbon1-512.png",iconWidth=50,iconHeight=65)
map<-leaflet()%>%
addTiles()%>%
addProviderTiles(providers$OpenStreetMap)%>%
addMarkers(lng=UK.map$long,lat=UK.map$lat,icon=newicon,clusterOptions = markerClusterOptions(),popup=paste("<h3>Info Table</h3>","<b>Distillery name:</b>",whiskey_db$Distiller,"<br>","<b>Body:</b>",whiskey$Body,"<br>","<b>Sweetness:</b>",whiskey$Sweetness,"<br>","<b>Smoky:</b>",whiskey$Smoky,"<br>","<b>Medicinal:</b>",whiskey$Medicinal,"<br>","<b>Tobacco:</b>",whiskey$Tobacco,"<br>","<b>Honey:</b>",whiskey$Honey,"<br>","<b>Spicy:</b>",whiskey$Spicy,"<br>","<b>Winey:</b>",whiskey$Winey,"<br>","<b>Nutty:</b>",whiskey$Nutty,"<br>","<b>Malty:</b>",whiskey$Malty,"<br>","<b>Fruity:</b>",whiskey$Fruity,"<br>","<b>Floral:</b>",whiskey$Floral,"<br>","<b>Postcode:</b>",whiskey$Postcode,"<br>","<b>Lattitude:</b>",whiskey$Latitude,"<br>","<b>Longitude:</b>",whiskey$Longitude))%>%addMiniMap()
setView(map,lng=-2.4333,lat=53.5500,zoom=9)
#
library(leaflet)
library(dplyr)
library(htmlwidgets)
library(htmltools)
tag.map.title <- tags$style(HTML("
.leaflet-control.map-title {
transform: translate(-50%,5%);
position: fixed !important;
left: 50%;
text-align: center;
color: black;
background:white;
font-weight: bold;
font-size: 15px;
}
"))
title <- tags$div(
tag.map.title, HTML("Whiskey Distillery Mapping:Based On Location")
)
newicon<-makeIcon(iconUrl="https://cdn0.iconfinder.com/data/icons/alcoholic/120/bourbon1-512.png",iconWidth=50,iconHeight=65)
map<-leaflet()%>%
addTiles(group = "Based on Location")%>%
addControl(title, position = "topleft", className="map-title")%>%
addProviderTiles(providers$OpenStreetMap)%>%
addMarkers(lng=UK.map$long,lat=UK.map$lat,icon=newicon,clusterOptions = markerClusterOptions(),popup=paste("<h3>Info Table</h3>","<b>Distillery name:</b>",whiskey_db$Distiller,"<br>","<b>Body:</b>",whiskey$Body,"<br>","<b>Sweetness:</b>",whiskey$Sweetness,"<br>","<b>Smoky:</b>",whiskey$Smoky,"<br>","<b>Medicinal:</b>",whiskey$Medicinal,"<br>","<b>Tobacco:</b>",whiskey$Tobacco,"<br>","<b>Honey:</b>",whiskey$Honey,"<br>","<b>Spicy:</b>",whiskey$Spicy,"<br>","<b>Winey:</b>",whiskey$Winey,"<br>","<b>Nutty:</b>",whiskey$Nutty,"<br>","<b>Malty:</b>",whiskey$Malty,"<br>","<b>Fruity:</b>",whiskey$Fruity,"<br>","<b>Floral:</b>",whiskey$Floral,"<br>","<b>Postcode:</b>",whiskey$Postcode,"<br>","<b>Lattitude:</b>",whiskey$Latitude,"<br>","<b>Longitude:</b>",whiskey$Longitude))%>%addMiniMap()%>%
addLayersControl(baseGroups = c("Based on Location"))
setView(map,lng=-2.4333,lat=53.5500,zoom=9)
#
library(leaflet)
library(dplyr)
library(htmlwidgets)
library(htmltools)
library(raster)
##
## Attaching package: 'raster'
## The following object is masked from 'package:dplyr':
##
## select
## The following object is masked from 'package:MASS':
##
## select
tag.map.title <- tags$style(HTML("
.leaflet-control.map-title {
transform: translate(-50%,5%);
position: fixed !important;
left: 50%;
text-align: center;
color: black;
background:white;
font-weight: bold;
font-size: 15px;
}
"))
title <- tags$div(
tag.map.title, HTML("Whiskey Distillery Mapping:Based On Body")
)
whiskey_db$`whiskey$Body` <- factor(whiskey_db$`whiskey$Body`)
new <- c("red", "green","blue","orange","yellow")[whiskey_db$`whiskey$Body`]
icons <- awesomeIcons(
icon = 'ios-close',
iconColor = 'black',
library = 'ion',
markerColor = new
)
unique_markers_map <- leaflet(whiskey_db$`whiskey$Body`)%>%
addTiles(group = "Based on Body")%>%
addControl(title, position = "topleft", className="map-title")%>%
addProviderTiles(providers$OpenStreetMap)%>%
addAwesomeMarkers(lng=UK.map$long,lat=UK.map$lat,icon=icons,clusterOptions = markerClusterOptions(),popup=paste("<h3>Info Table</h3>","<b>Distillery name:</b>",whiskey_db$Distiller,"<br>","<b>Body:</b>",whiskey$Body,"<br>","<b>Sweetness:</b>",whiskey$Sweetness,"<br>","<b>Smoky:</b>",whiskey$Smoky,"<br>","<b>Medicinal:</b>",whiskey$Medicinal,"<br>","<b>Tobacco:</b>",whiskey$Tobacco,"<br>","<b>Honey:</b>",whiskey$Honey,"<br>","<b>Spicy:</b>",whiskey$Spicy,"<br>","<b>Winey:</b>",whiskey$Winey,"<br>","<b>Nutty:</b>",whiskey$Nutty,"<br>","<b>Malty:</b>",whiskey$Malty,"<br>","<b>Fruity:</b>",whiskey$Fruity,"<br>","<b>Floral:</b>",whiskey$Floral,"<br>","<b>Postcode:</b>",whiskey$Postcode,"<br>","<b>Lattitude:</b>",whiskey$Latitude,"<br>","<b>Longitude:</b>",whiskey$Longitude))%>%addMiniMap()%>%addLegend(color="yellow",labels="Body 1")%>%addLegend(color="green",labels="Body 1")%>%addLegend(color="blue",labels="Body 2")%>%addLegend(color="orange",labels="Body 3")%>%addLegend(color="red",labels="Body 4")%>%
addLayersControl(baseGroups = c("Based on Body"))
setView(unique_markers_map,lng=-2.4333,lat=53.5500,zoom=9)
#
library(leaflet)
library(dplyr)
library(htmlwidgets)
library(htmltools)
library(raster)
tag.map.title <- tags$style(HTML("
.leaflet-control.map-title {
transform: translate(-50%,5%);
position: fixed !important;
left: 50%;
text-align: center;
color: black;
background:white;
font-weight: bold;
font-size: 15px;
}
"))
title <- tags$div(
tag.map.title, HTML("Whiskey Distillery Mapping:Based On Spicy")
)
whiskey_db$`whiskey$Spicy` <- factor(whiskey_db$`whiskey$Spicy`)
new <- c("red", "green","blue","orange","yellow")[whiskey_db$`whiskey$Spicy`]
icons <- awesomeIcons(
icon = 'ios-close',
iconColor = 'black',
library = 'ion',
markerColor = new
)
unique_markers_map <- leaflet(whiskey_db$`whiskey$Spicy`)%>%
addTiles(group = "Based on Spicy")%>%
addControl(title, position = "topleft", className="map-title")%>%
addProviderTiles(providers$OpenStreetMap)%>%
addAwesomeMarkers(lng=UK.map$long,lat=UK.map$lat,icon=icons,clusterOptions = markerClusterOptions(),popup=paste("<h3>Info Table</h3>","<b>Distillery name:</b>",whiskey_db$Distiller,"<br>","<b>Body:</b>",whiskey$Body,"<br>","<b>Sweetness:</b>",whiskey$Sweetness,"<br>","<b>Smoky:</b>",whiskey$Smoky,"<br>","<b>Medicinal:</b>",whiskey$Medicinal,"<br>","<b>Tobacco:</b>",whiskey$Tobacco,"<br>","<b>Honey:</b>",whiskey$Honey,"<br>","<b>Spicy:</b>",whiskey$Spicy,"<br>","<b>Winey:</b>",whiskey$Winey,"<br>","<b>Nutty:</b>",whiskey$Nutty,"<br>","<b>Malty:</b>",whiskey$Malty,"<br>","<b>Fruity:</b>",whiskey$Fruity,"<br>","<b>Floral:</b>",whiskey$Floral,"<br>","<b>Postcode:</b>",whiskey$Postcode,"<br>","<b>Lattitude:</b>",whiskey$Latitude,"<br>","<b>Longitude:</b>",whiskey$Longitude))%>%addMiniMap()%>%addLegend(color="yellow",labels="Spicy 1")%>%addLegend(color="green",labels="Spicy 1")%>%addLegend(color="blue",labels="Spicy 2")%>%addLegend(color="orange",labels="Spicy 3")%>%addLegend(color="#ff0000",labels="Spicy 4")%>%
addLayersControl(baseGroups = c("Based on Spicy"))
setView(unique_markers_map,lng=-2.4333,lat=53.5500,zoom=9)
library(leaflet)
library(dplyr)
library(htmlwidgets)
library(htmltools)
library(raster)
tag.map.title <- tags$style(HTML("
.leaflet-control.map-title {
transform: translate(-50%,5%);
position: fixed !important;
left: 50%;
text-align: center;
color: black;
background:white;
font-weight: bold;
font-size: 15px;
}
"))
title <- tags$div(
tag.map.title, HTML("Whiskey Distillery Mapping:Based On Sweetness")
)
whiskey_db$`whiskey$Sweetness` <- factor(whiskey_db$`whiskey$Sweetness`)
new <- c("red", "green","blue","orange","yellow")[whiskey_db$`whiskey$Sweetness`]
icons <- awesomeIcons(
icon = 'ios-close',
iconColor = 'black',
library = 'ion',
markerColor = new
)
unique_markers_map <- leaflet(whiskey_db$`whiskey$Sweetness`)%>%
addTiles(group = "Based on Sweetness")%>%
addControl(title, position = "topleft", className="map-title")%>%
addProviderTiles(providers$OpenStreetMap)%>%
addAwesomeMarkers(lng=UK.map$long,lat=UK.map$lat,icon=icons,clusterOptions = markerClusterOptions(),popup=paste("<h3>Info Table</h3>","<b>Distillery name:</b>",whiskey_db$Distiller,"<br>","<b>Body:</b>",whiskey$Body,"<br>","<b>Sweetness:</b>",whiskey$Sweetness,"<br>","<b>Smoky:</b>",whiskey$Smoky,"<br>","<b>Medicinal:</b>",whiskey$Medicinal,"<br>","<b>Tobacco:</b>",whiskey$Tobacco,"<br>","<b>Honey:</b>",whiskey$Honey,"<br>","<b>Spicy:</b>",whiskey$Spicy,"<br>","<b>Winey:</b>",whiskey$Winey,"<br>","<b>Nutty:</b>",whiskey$Nutty,"<br>","<b>Malty:</b>",whiskey$Malty,"<br>","<b>Fruity:</b>",whiskey$Fruity,"<br>","<b>Floral:</b>",whiskey$Floral,"<br>","<b>Postcode:</b>",whiskey$Postcode,"<br>","<b>Lattitude:</b>",whiskey$Latitude,"<br>","<b>Longitude:</b>",whiskey$Longitude))%>%addMiniMap()%>%addLegend(color="yellow",labels="Sweetness 1")%>%addLegend(color="green",labels="Sweetness 1")%>%addLegend(color="blue",labels="Sweetness 2")%>%addLegend(color="orange",labels="Sweetness 3")%>%addLegend(color="red",labels="Sweetness 4")%>%
addLayersControl(baseGroups = c("Based on Sweetness"))
setView(unique_markers_map,lng=-2.4333,lat=53.5500,zoom=9)
The intended visualization was much effective as apart from just knowing the location, we inteded to increase the interactivity of the map by adding waterfall plot that could help compare nearby distilleries by clicking on the clustered markers but it could be only achieved through shiny. For, the current visualization, from a user’s perspective, it was crucial to know where the distilleries were located and the best way that could be achieved was through a map. The map also shows the distilleries information which would be very useful when once know the location of the distillery.
Features of the distilleries could be compared with shiny by creating an onclick event thrugh shiny and producing a bubble chart or radar plot but here, in this visualization, we have focused on based on features, if a user wants to know the place of the distillery, could know it through a map. The coloured markers are associated with the fetaure type and offcouse the markers contain other information as well.
The map contains a proper view set through SetView that produces the desired zoomed view, the provider is selected keeping in mind proper display of the map. To avoid clustering clusterOption is used. LayerControl and Mini Maps also added for the right reason. Interactivity through a map is produced to the maximum limit but the map does not have the desired legend table. The legends produced are not at all effective.